<div class="container-fluid">
	
<div class="col-md-3 bg-light dk b-r fl mt15" style="padding: 0;">
	
	<div class="wrapper bg b-b">
      <h3 class="m-n font-thin">门票</h3>
    </div>

    <div class="wrapper">
      <form class="ng-pristine ng-valid ng-submitted">
        <div class="form-group">
          <label>门票名称</label>
          <input type="text" class="input-sm form-control" ng-model="ticket.name"
          value="{{ticket.name}}" 
          >
        </div>
        <div class="form-group">
          <div >
          <label>所属商家</label>
          <button type="button" class="btn btn-success btn-xs pull-right"
          ng-click="createPlace()"
          >创建商家</button>
          </div>
          <div>
            <ui-select multiple ng-model="ticket.place_code_array" theme="bootstrap" >
                <ui-select-match placeholder="选择一个商家，如果没有创建一个⬆️">
                    <!-- {{$select.selected.name}} -->
                    {{$item.name}}
                </ui-select-match>
                <ui-select-choices repeat="item.code as item in view_array | filter: $select.search">
                    <span ng-bind-html="item.name | highlight: $select.search"></span>
                    【<span ng-bind-html="item.code | highlight: $select.search"></span> 】
                </ui-select-choices>
            </ui-select>
          </div>
          
        </div>

        <div class="form-group">
          	<label>有效期</label>

          	<input type="text" class="form-control input-sm" ng-model="s" 
            datetimepicker readonly
            options="vm1.options"
            >

            <input type="text" class="form-control input-sm" ng-model="e" 
            datetimepicker readonly
            options="vm1.options"
            >

        </div>

        <div class="form-group row">
            <label class="col-sm-5 control-label">需要预约</label>
            <div class="col-sm-7">
              <label class="i-switch m-r">
                <input type="checkbox" 
                  ng-checked="ticket.appoint == '1'"
                  name="ticket.appoint"
                  ng-true-value="'1'"
                  ng-false-value="'0'"
                  ng-model="ticket.appoint"
                >
                <i></i>
              </label>
            </div>

        </div>


        <div class="m-t-md m-b-md">
        	<button class="btn btn-sm btn-primary"
          ng-click="addTicket()"
          >
        		添加一个门票
        	</button>
        </div>
      </form>
    </div>

</div>

<div class="col-md-9 fl">
	
	<div class="wrapper">
		
		<div class="panel" 
    ng-class="{true: 'panel-success', false: 'panel-danger'}[obj.is_available == '0']"
    ng-repeat="obj in p.ticketlist">
          
          <div class="wrapper-lg">
            <!-- <button type="button" class="close" 
            ng-if="obj.is_available == '1'"
            ng-click="recoveryTicket(obj)"
            >
              <span class="glyphicon glyphicon-eye-close" aria-hidden="true"></span>
            </button>

            <button type="button" class="close" 
            ng-if="obj.is_available == '0'"
            ng-click="delTicket(obj)"
            >
              <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
            </button> -->
            
            
            <h2 class="m-t-none" ng-if="obj.opt.name == '0'" style="cursor: pointer;" >
            <span ng-click="changeOpt(obj, 'name')">{{obj.name}}</span>
            <small ng-if="obj.is_available == '1'" class="text-danger"
            ng-click="recoveryTicket(obj)"
            >不出票</small>
            <small ng-if="obj.is_available == '0'" class="text-success"
            ng-click="delTicket(obj)"
            >出票</small>
            </h2>

            <div class="input-group" 
            style="width: 400px; margin-bottom: 10px;" 
            ng-if="obj.opt.name == '1'">
              <input type="text" class="form-control" 
              ng-model="obj.name"
              >
              <span class="input-group-btn">
                <button class="btn btn-default" type="button"
                ng-click="setName(obj)"
                >OK</button>
              </span>
              <span class="input-group-btn">
                <button class="btn btn-default" type="button"
                ng-click="changeOpt(obj, 'name')"
                >Cancel</button>
              </span>
            </div><!-- /input-group -->

            <div style="cursor: pointer; float: left;"
            ng-if="obj.opt.period == '0'"
            ng-click="changeOpt(obj,'period')"
            >
            	<p>有效期：{{obj.periodstart}} 至 {{obj.periodend}}</p>
            	
            </div>
            <div 
            ng-if="obj.opt.period == '1'"
            >
                <div class="fl">有效期：</div>

                <input class=" fl" datetimepicker readonly
                ng-model="obj.periodstart_date" 
                options="vm1.options"
                style="border: none; width: 110px; border-bottom: 1px solid #aaa;"
                />
                <div class="fl"> 至 </div>
                <input class=" fl ml10" datetimepicker readonly
                ng-model="obj.periodend_date" 
                options="vm1.options"
                style="border: none; width: 110px; border-bottom: 1px solid #aaa;"
                />

                <button type="button" class="btn btn-default btn-sm fl ml10"
                ng-click="setPeriod(obj)"
                >
                OK
                </button>

            </div>
            <div class="fl">&nbsp;&nbsp; | &nbsp;&nbsp;</div>
            <div style="cursor: pointer; float: left;"
            ng-if="obj.opt.appoint == '0'"
            ng-click="changeOpt(obj,'appoint')"
            >
              <p ng-if="obj.appoint == '0'"> 无需预约 </p>
              <p ng-if="obj.appoint == '1'"> 需要预约 </p>
              
            </div>

            <div 
            ng-if="obj.opt.appoint == '1'"
            >
                <div class="fl">预约：</div>

                <div class="fl">
                <label class="i-switch m-r">
                  <input type="checkbox" 
                    ng-checked="obj.appoint == '1'"
                    name="obj.appoint"
                    ng-true-value="'1'"
                    ng-false-value="'0'"
                    ng-model="obj.appoint"
                  >
                  <i></i>
                </label>
                </div>
                
                <button type="button" class="btn btn-default btn-sm fl ml10"
                ng-click="setAppoint(obj)"
                >
                OK
                </button>

            </div>



            <div ng-repeat="place in obj.placelist" >
              <div class="line line-lg b-b b-light"></div>
              <button type="button" class="close" aria-label="Close"
              ng-if="obj.placelist.length > 1"
              ng-click="delPlace(obj,$index)"
              >
              <span aria-hidden="true">&times;</span></button>
              <div class="mt10" style="cursor: pointer;"
              ng-click="createPlace(place)"
              >
              	<p>商家信息：{{place.name}} , {{place.mobile}} , {{place.open_time}}</p>
              	<p>商家地址：{{place.address}}</p>
              </div>
              <!-- <div class="line line-lg b-b b-light"></div> -->
              	<span>核销设备：
                  <span ng-repeat="device in place.devicelist"
                  ng-click="createDevice(place, device)"
                  style="cursor: pointer;" 
                  >
                    {{device.code}} , 
                  </span>
                </span>
              	<a href ng-click="createDevice(place)"> 添加一个核销设备 </a>
            </div>


           <!--  <button type="button" class="btn btn-info btn-sm mt10"
            ng-click="addPlace(obj)"
            >
              为该票种添加一个通用商家
            </button>
            
 -->
          </div>
        </div>

        

	</div>
</div>

	
</div>